package ntd.util.frame.server.context;

import cn.hutool.core.convert.Convert;
import lombok.Data;
import ntd.block.server.ComServer;
import ntd.block.server.context.NtdContextAction;
import ntd.util.config.common.enums.app.EnumServerAppType;
import ntd.util.modular.function.entity.ServerApp;

import java.util.ArrayList;
import java.util.List;

@Data
public class ContextServer {

    /** 主机host */
    private String host;
    /** 主机端口 */
    private Integer port;
    /** 唯一标识 */
    private String code;
    /** 应用对象 */
    private ComServer ComServer;
    /** 应用对象类型 */
    private EnumServerAppType enumServerAppType;
    /** 处理Action */
    private List<NtdContextAction> contextActionList = new ArrayList<>();

    public static ContextServer transformContext(ServerApp serverApp) {
        ContextServer contextServer = new ContextServer();
        contextServer.setPort(Convert.toInt(serverApp.getPort()));
        contextServer.setCode(serverApp.getId());
        contextServer.setEnumServerAppType(serverApp.getEnumServerAppType());
        return contextServer;
    }

}
